package com.servicesystem.servicesystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.servicesystem.servicesystem.mapper.AliOrderLogisticsDao;
import com.servicesystem.servicesystem.entity.AliOrderLogistics;
import com.servicesystem.servicesystem.service.AliOrderLogisticsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (AliOrderLogistics)表服务实现类
 *
 * @author makejava
 * @since 2020-09-16 16:48:35
 */
@Service("aliOrderLogisticsService")
public class AliOrderLogisticsServiceImpl extends ServiceImpl<AliOrderLogisticsDao, AliOrderLogistics> implements AliOrderLogisticsService {

    @Override
    public void fixLogistics(String aliOrderId, String logisticsId, String logisticsName) {
        QueryWrapper<AliOrderLogistics> aliOrderLogisticsQueryWrapper = new QueryWrapper<>();
        aliOrderLogisticsQueryWrapper.eq("ali_order_id", aliOrderId);
        AliOrderLogistics aliOrderLogistics = baseMapper.selectOne(aliOrderLogisticsQueryWrapper);
        aliOrderLogistics.setLogisticsId(logisticsId);
        aliOrderLogistics.setLogisticsName(logisticsName);
        aliOrderLogistics.setStatus(1);
        baseMapper.updateById(aliOrderLogistics);
    }

    /***
     * 查询ali订单物流表
     * @param orderId
     * @return
     */
    @Override
    public AliOrderLogistics getLogisticsAdd(String orderId) {
        QueryWrapper<AliOrderLogistics> aliOrderLogisticsQueryWrapper = new QueryWrapper<>();
        aliOrderLogisticsQueryWrapper.eq("tt_order_id", orderId);
        AliOrderLogistics aliOrderLogistics = baseMapper.selectOne(aliOrderLogisticsQueryWrapper);
        return aliOrderLogistics;
    }

    /***
     * 查询全部ali订单物流列表
     * @return
     */
    @Override
    public List<AliOrderLogistics> getLogisticsList() {
        List<AliOrderLogistics> aliOrderLogistics = baseMapper.selectList(null);
        return aliOrderLogistics;
    }


    @Override
    public AliOrderLogistics getLogisticsByAliOrderId(String aliOrderId) {
        QueryWrapper<AliOrderLogistics> aliOrderLogisticsQueryWrapper = new QueryWrapper<>();
        aliOrderLogisticsQueryWrapper.eq("ali_order_id", aliOrderId);
        AliOrderLogistics aliOrderLogistics = baseMapper.selectOne(aliOrderLogisticsQueryWrapper);
        return aliOrderLogistics;
    }
}
